Skip to content

Catering to all possible routes for Post Request#700

Merged
mukundansundar merged 6 commits into
dapr:masterfrom
DeepanshuA:issue694
Mar 21, 2022
Merged

Catering to all possible routes for Post Request#700
mukundansundar merged 6 commits into
dapr:masterfrom
DeepanshuA:issue694

Conversation

@DeepanshuA

@DeepanshuA DeepanshuA commented Mar 9, 2022

Copy link
Copy Markdown
Contributor

Signed-off-by: deepanshuagarwal deepanshu.agarwal1984@gmail.com

Description

A topic is getting subscribed to in Dapr with a truncated path, in case a class level RequestMapping is also provided with PostMapping path. This change aims at fixing this by taking into account all paths possible for POST.

Issue reference

Please reference the issue this PR will close: #694

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

@DeepanshuA DeepanshuA requested review from a team as code owners March 9, 2022 07:07
@mukundansundar

Copy link
Copy Markdown
Contributor

@DeepanshuA Please see to the indentation ... Viewing via GitHub is hard ... please check if the checkstyle passes locally ...

1 similar comment
@mukundansundar

Copy link
Copy Markdown
Contributor

@DeepanshuA Please see to the indentation ... Viewing via GitHub is hard ... please check if the checkstyle passes locally ...

@mukundansundar mukundansundar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. @DeepanshuA Can you look into adding Unit Tests for the same?

@mukundansundar

Copy link
Copy Markdown
Contributor

@DeepanshuA
Can you fix DCO ? Also is the PR complete or WIP ?

@DeepanshuA

Copy link
Copy Markdown
Contributor Author

@DeepanshuA Please see to the indentation ... Viewing via GitHub is hard ... please check if the checkstyle passes locally ...

yeah @mukundansundar, fixed indentation

@DeepanshuA

Copy link
Copy Markdown
Contributor Author

@DeepanshuA Please see to the indentation ... Viewing via GitHub is hard ... please check if the checkstyle passes locally ...

fixed indentation

@DeepanshuA

Copy link
Copy Markdown
Contributor Author

lgtm. @DeepanshuA Can you look into adding Unit Tests for the same?

yups, added, was in WIP actually before this

@DeepanshuA

Copy link
Copy Markdown
Contributor Author

@DeepanshuA Can you fix DCO ? Also is the PR complete or WIP ?

yeah @mukundansundar, missed out on sign-off part, let me fix it; yeah, will change the title - it will be PR complete after DCO change.

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>
Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>
@DeepanshuA DeepanshuA changed the title [WIP] Catering to all possible routes for Post Request Catering to all possible routes for Post Request Mar 16, 2022
@DeepanshuA DeepanshuA requested review from mukundansundar and removed request for a team March 16, 2022 12:54

@mukundansundar mukundansundar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small change

Comment thread sdk-springboot/src/main/java/io/dapr/springboot/DaprBeanPostProcessor.java Outdated
Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>
mukundansundar
mukundansundar previously approved these changes Mar 16, 2022
@mukundansundar

Copy link
Copy Markdown
Contributor

cc @artursouza

* @param topicName Associated topic name
* @return All possible routes for post mapping for this class and post method
*/
public static List<String> getAllCompleteRoutesForPost(Class clazz, Method method, String topicName) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, move this as a private method in DaprBeanPostProcessor. The reason is that this design will make this method public and part of our contract - in other words, users can depend on this method. Marking it as private makes it clear that is internal use only. Unfortunately, we don't have an internal visibility, only protected, public, private and default.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that this will expose it without need of exposing. Though, just thinking that at least taking out some methods with default access (package private)/ protected may be required, if refactoring a huge class OR using a required design pattern may force us making some extra methods/interfaces public sometimes. BUT, that's not the case with DaprBeanPostProcessor as of now. So, making the suggested change.


@Test
public void testAllPostRoutesGeneration() throws NoSuchMethodException {
List<String> routesArrayTestMethod1 = SpringProcessorHelper.getAllCompleteRoutesForPost(clazzToBeTested,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this method is made private, you can still test it via reflection.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

@mukundansundar mukundansundar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@codecov

codecov Bot commented Mar 21, 2022

Copy link
Copy Markdown

Codecov Report

Merging #700 (cee4dd2) into master (06d92da) will decrease coverage by 1.52%.
The diff coverage is 68.42%.

@@             Coverage Diff              @@
##             master     #700      +/-   ##
============================================
- Coverage     79.62%   78.10%   -1.53%     
- Complexity     1092     1106      +14     
============================================
  Files            92       97       +5     
  Lines          3308     3407      +99     
  Branches        376      394      +18     
============================================
+ Hits           2634     2661      +27     
- Misses          482      547      +65     
- Partials        192      199       +7     
Impacted Files Coverage Δ
...java/io/dapr/springboot/DaprBeanPostProcessor.java 42.18% <68.42%> (ø)
...java/io/dapr/springboot/DaprTopicSubscription.java 0.00% <0.00%> (ø)
.../src/main/java/io/dapr/springboot/DaprRuntime.java 0.00% <0.00%> (ø)
...java/io/dapr/springboot/DaprAutoConfiguration.java 0.00% <0.00%> (ø)
...c/main/java/io/dapr/springboot/DaprController.java 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 06d92da...cee4dd2. Read the comment docs.

@mukundansundar mukundansundar merged commit 593da48 into dapr:master Mar 21, 2022
fackee pushed a commit to fackee/java-sdk that referenced this pull request Mar 28, 2022
* Catering to all possible routes for Post Request

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Correcting checkstyle related violations

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Refactoring and Adding UTs for post method routes

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Using resolved topic name

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Shifting routesPostMethod to reduce its access

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com>
Signed-off-by: zjx244729 <zjx244729@alibaba-inc.com>
fackee pushed a commit to fackee/java-sdk that referenced this pull request Mar 28, 2022
* Catering to all possible routes for Post Request

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Correcting checkstyle related violations

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Refactoring and Adding UTs for post method routes

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Using resolved topic name

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Shifting routesPostMethod to reduce its access

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com>
Signed-off-by: zjx244729 <zjx244729@alibaba-inc.com>
fackee pushed a commit to fackee/java-sdk that referenced this pull request Mar 28, 2022
* Catering to all possible routes for Post Request

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Correcting checkstyle related violations

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Refactoring and Adding UTs for post method routes

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Using resolved topic name

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Shifting routesPostMethod to reduce its access

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com>
Signed-off-by: zjx244729 <zjx244729@alibaba-inc.com>
fackee pushed a commit to fackee/java-sdk that referenced this pull request Mar 28, 2022
* Catering to all possible routes for Post Request

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Correcting checkstyle related violations

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Refactoring and Adding UTs for post method routes

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Using resolved topic name

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Shifting routesPostMethod to reduce its access

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com>
Signed-off-by: zjx244729 <zjx244729@alibaba-inc.com>
fackee pushed a commit to fackee/java-sdk that referenced this pull request Mar 28, 2022
* Catering to all possible routes for Post Request

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Correcting checkstyle related violations

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Refactoring and Adding UTs for post method routes

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Using resolved topic name

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Shifting routesPostMethod to reduce its access

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com>
Signed-off-by: zjx244729 <zjx244729@alibaba-inc.com>
artursouza pushed a commit to pkedy/java-sdk that referenced this pull request Jun 22, 2022
* Catering to all possible routes for Post Request

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Correcting checkstyle related violations

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Refactoring and Adding UTs for post method routes

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Using resolved topic name

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

* Shifting routesPostMethod to reduce its access

Signed-off-by: deepanshuagarwal <deepanshu.agarwal1984@gmail.com>

Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spring-boot: Using @Topic annotation reads the path from methods' @PostMapping, ignoring class-level @RequestMapping

3 participants